﻿	//add by liyang 20070801
	function KeyDown(value)
    {
        if (event.keyCode == 13)
        {
			var bz = /^\d{1,3}$/.test(value);
			if(!bz){
				alert("输入有误");
				return false;
			}
            event.returnValue=false;
            event.cancel = true;
            go_general_query('resultlist');
        }
		return false;
    }
	//删除displaytag的 span标签
	function deletespan(){
        var spanarray = document.getElementsByTagName("span");
        for (var i=0; i<spanarray.length; i++){
	        var spanclass = spanarray[i].getAttributeNode("class").nodeValue;
	        if (spanclass=="pagebanner"||spanclass=="pagelinks"||spanclass=="pagebanner"){
		        spanarray[i].innerText="";
	        }
        }
    }
	//add by liyang 20070801


	function formSerializer(form)
	{
		var myform = $(form);
		var val = "";
		var sendData = "";
		for (i=0;i<myform.elements.length;i++)
		{
			element = myform.elements[i]
			if(element.type && (element.type=="radio" || element.type=="checkbox"))
			{
				if(element.checked)
				{
					sendData += element.name + "=" + element.value + "&";
				}
			}
			else
			{
				val = element.value;
				//if (element.type=="textarea"||element.type=="text")
				if (element.type=="textarea"||element.type=="text"||element.type=="hidden")
				{
				    val = encodeURI(val);
					//val = escape(val);
				}
			
				sendData += element.name + "=" + val + "&";
			}
		}
		return sendData;
	}
//----------------------------------------------------------------------------------------------------//
	function loadXMLDoc2Div(url,div,params){
		if(!params)params="";
		var updater = new Ajax.Request(url, {asynchronous: false,evalScripts:true,method: 'post', parameters: params});
		var text = updater.transport.responseText;
		$(div).innerHTML = text;;
		text.evalScripts();
	}	

	function submitXMLDoc2Div(myform,url,div){		
		if(undefined==div){
			div = "resultlist";
		}
		var params = formSerializer($(myform));
		var updater = new Ajax.Request(url, {asynchronous: false,evalScripts:true,contentType:'application/x-www-form-urlencoded;charset=utf-8',method: 'post', parameters: params});
		
		var text = updater.transport.responseText;
	
		$(div).innerHTML = text;
		text.evalScripts();
		//add by liyang
		deletespan();
		//add by liyang
	}
//----------------------------------------------------------------------------------------------------//
	/*
	initSelect
	*/
	function initSelect(elementID,dictionary,condition,value)
	{
		var list;
		if(dict_list.indexOf("," + dictionary + ",")>=0)
		{
			var s = eval("dict_"+dictionary);
			list = s.split(/[=;]/);
		}
		else
		{
			var xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
			var url = app_path + "/public/dictionary/dictionarySelect.do?method=getQueryList&XT_TYKJ_KJMC=" + dictionary + "&change=null&CONDITION=" + condition + "&returnList=&returnInputList=&rootName=";
			xmlhttp.Open("POST",url,false);
			xmlhttp.send(null);
			var res=xmlhttp.responseText;
			var doc=new ActiveXObject("MSXML.DOMDocument");
			doc.async=false;
			doc.loadXML(res);
			var root = doc.documentElement;
			list = new Array();
			var oNodeList = root.childNodes;
			for (var i=0; i<oNodeList.length; i++) 
			{
			  	var Item = oNodeList.item(i);
			  	var dc=Item.childNodes;
			  	list[2*i] = dc[0].firstChild.text;
			  	list[2*i+1] = dc[1].firstChild.text;
			}
		}
		var defaultvalue = value;
		var element = $(elementID);
		
		if(element.value!="")
		{
			defaultvalue = element.value;
		}
	
		var strOption="<SELECT style='width:120px' NAME='" + elementID + "' origin='" + defaultvalue + "'/>";
		var op=document.createElement(strOption);
		op.options[0]=new Option("\u8BF7\u9009\u62E9","");
		var selectedText = defaultvalue;
		for(var i=0; i<list.length/2; i++)
		{
		 	op.options[i+1]=new Option(list[2*i+1],list[2*i]);
			if(list[2*i]==defaultvalue||list[2*i+1]==defaultvalue)        
		    {
		        op.options[i+1].selected=true;
			}
		}
//		op.options.sort(function(a,b){return a.value < b.value ? -1 : a > b ? 1 : 0});
		if(!op.selectedIndex || op.selectedIndex<0)
		{
			op.selectedIndex=0;
			op.origin="";
		}
		if(page_type=="view" && element.tagName.toLowerCase()=="span")
		{
			var sText = "";
			if(op.selectedIndex && op.selectedIndex>0)
			{
				sText = op[op.selectedIndex].text;
			}
			element.innerText = sText;
		}
		else
		{
			if(element.validator)
			{
				/* update by liyangc 2007-04-13 */
				//alert('common 1111111111');
				op.validator=element.validator;
				/*
				if(op.validator.find(function(value){return value=="required"})){
					 
					op.removeChild(op.options[0]);
				}
				*/
			}
			p = element.parentNode;
			p.insertBefore(op,element);
			p.removeChild(element);
		}	
	}	
//----------------------------------------------------------------------------------------------------//
	function removeRefreshCookie()
	{
		s = getCookie("token_cookie");
		document.cookie = "token_cookie=temp_" + s;
		pbuttonDisable();
	}
	
	function getCookie(s)
	{
		var arr=document.cookie.split(/[=;]/);
		for(var i=0;i<arr.length;i+=2)
		{
		      if(s==arr[i])
		      {
		             return arr[++i];
		      }		      
		 }
		 return "";
	}
	
	function submit2dialog(url)
	{
		newwin=window.open(url,"window");
		newwin.focus();
	}
	
	function submitForm(form)
	{
		form = form?$(form):document.forms[0];
		if(valid.validate())
		{			
			initBgdiv();
			var frame = document.createElement("<iframe id='openwin' height='100%' width='100%' src='' margin='0' border='0'></iframe>");		
			frame.frameBorder = "0"; 
			$("bgdiv").appendChild(frame);
			//alert(' submit');
			form.submit();
		}

	}
	
	function getKey4Validate(key)
	{
		return ($F(key) && $F(key).length>0)?$F(key):" ";
	}
	
	function doSubForm(key,url)
	{
		window.location.href = url + $F(key);
	}
	
	/* update by liyang 2008-01-29 */
	function go_general_query(position,totalpage){
	    var pageNum = document.all("go").value;
	    
      if(!isNumber(pageNum)){
      	  alert('请输入正整数');
      	  return ;
      }	

	    if(pageNum!=null&&pageNum!=""&&pageNum>0){
	        if((parseInt(totalpage))<(parseInt(pageNum))){
	        	general_query(totalpage,position,1);
	        }
	        else{
	        	general_query(pageNum-1,position,1);
	        }
	    }
	}
	/* add by liyang 2007-04-16 */
	 function isNumber(oNum){
       if(!oNum){
           return false;
       }
       var strP=/^\d+(\.\d+)?$/;
       if(!strP.test(oNum)){
           return false;
       }
       try{
           if(parseInt(oNum)!=oNum||parseInt(oNum)==0){
           return false;
       }
       }catch(ex){
           return false;
       }
       return true;
   }
//-->
//----------------------------------------------------------------------------------------------------//
/*
*/
function general_query(pageNum,position,type){
	$("pageNum").value = pageNum;
	if(type){
		if($("total_num") && parseInt($("total_num").innerText)>0){
			$("recordNum").value=$("total_num").innerText;
		}
	}else{
		$("recordNum").value = "";
	}
	if(form_validator(document.forms[0])){
		submitXMLDoc2Div(document.forms[0],app_path+'/common/generalquery_result.do',position);
	}
}

function general_reset(formName){
	var formObj = document.forms[formName];     
	var formEl = formObj.elements;     
	for (var i=0; i<formEl.length; i++)     {        
		var element = formEl[i];        
		if (element.type == 'submit') { continue; }         
		if (element.type == 'reset') { continue; }        
		if (element.type == 'button') { continue; }         
		if (element.type == 'hidden') { continue; }          
		if (element.type == 'text') { element.value = ''; }         
		if (element.type == 'textarea') { element.value = ''; }         
		if (element.type == 'checkbox') { element.checked = false; }         
		if (element.type == 'radio') { element.checked = false; }         
		if (element.type == 'select-multiple') { element.selectedIndex = 0; }         
		if (element.type == 'select-one') { element.selectedIndex = 0; }     
	} 
}


function focusEnterToNextFocus(){
	if(event.keyCode==13){
		event.keyCode=9;
		event.returnValue=true;	
		return false;
	}	
	return false;
}

/*
*/
function form_validator(form){
	var i;
	for (i=0;i<form.elements.length;i++){//
		if (form.elements[i].type=="text" && form.elements[i].value!="" && form.elements[i].datatype){
			if(form.elements[i].datatype=="number" && isNaN(form.elements[i].value)){
				showMessage(form.elements[i],"???????");
				return false;
			}
		}
	}
	return true;
}

function showMessage(field,message)
{
	field.focus();
	field.select();
	showAlert(getElementTitle(field) + message,field);
}
function getElementTitle(elm)
{
	var s = "";
	try
	{
		if(elm.length && elm.length>0 && elm[0].tagName=="INPUT")elm = elm[0];
		s = elm.parentNode.previousSibling.innerText;
		if(s.charAt(s.length-1)=="*")s = s.substring(0,s.length-1);
	}catch(e){}
	return s;
}
function SelectDMTree(kjmc,inputKey,inputName)
{
	var htmlurl = app_path + "/public/dictionary/dictionaryTreeOrList.do?method=treeOrList&XT_TYKJ_KJMC="+kjmc+"&inputKey="+inputKey+"&inputName="+inputName;
	newwin=window.open(htmlurl,"homeWin","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=580,height=480,left=250,top=150");
	newwin.focus();
		 
	return false;
}	

function inputDisable(fields)
{
	var arr = fields.split(/[,]/);
	for(var i=0;i<arr.length;i++)
	{
		var element = document.all(arr[i]);
		try
		{
			if(element.type=="hidden")
			{
				element = document.all('c_' + element.name);//checkbox
				if(!element.length)
				{
					message("ALERT",arr[i] + "is hidden, you are crazy");
				}
			}
		}
		catch(e){}
		if(element.tagName && element.tagName.toUpperCase()=="SELECT")  //select
		{
			if(!element.origin)
			{
				element.origin = element.value;
			}
			element.onchange = reValueCheck;	
			element.className = "disable";
			element.onselectstart=returnFalse;
			element.onclick=returnFalse;
		}
		else if(element.type && element.type.toLowerCase()=="checkbox")//checkbox
		{
			element.onclick = reValueCheck;
		}
		else if(element.length && element.length>1) //radio and checkbox
		{
			for(var j=0; j<element.length; j++)
			{
				element[j].origin = element[j].checked;
				element[j].onclick = reValueCheck;
			}
		}
		else
		{
			try
			{
				element.readOnly = true;
				element.style.bgcolor="#E3EFF8";
				element.style.color="gray";
				element.onblur = returnFalse;
				element.onselectstart=returnFalse;
				try
				{
					if(element.nextSibling.outerHTML.indexOf("DateInputInner_onclick")>0)
					{
						element.parentNode.removeChild(element.nextSibling);
					}
				}
				catch(e){}
			}
			catch(e){}
		}
	}
}

function returnFalse()
{
	return false;
}

function getSelectText(element)
{
	element = $(element)
	var text = element.options[element.selectedIndex].text;
	if(element.selectedIndex==0 && element.value=="")
	{
		text = "";
	}
	return text;
}

	function elementSpy(element,value)
	{
		try
		{
			$("v_" + element.name).value = value;
		}
		catch(e){}	
	}

function input2text(fields)
{
	var arr = fields.split(/[,]/);
	var n = 0;
	var a = new Array();
	for(var i=0;i<arr.length;i++)
	{
		try
		{
			var element = $(arr[i]);
			try
			{
				//try dictcheckbox
				if(element.type=="hidden")
				{
					element = getInputSelector("c_" + element.name);
				}
				else if(!element || element.type.toLowerCase()=="radio")
				{
					element = getInputSelector(element.name);
				}
			}
			catch(e){}
			//text and select
			if(!element.length || element.tagName=="SELECT")
			{
				a[n++] = $(arr[i]);
				try
				{
					if(element.nextSibling.tagName=="IMG" || element.nextSibling.tagName=="A")
					{
						element.parentNode.removeChild(element.nextSibling);
					}
				}
				catch(e){}
			}
			else if(element.length && element.length>1)
			{
				for(var j=0;j<element.length;j++)
				{
					a[n++] = element[j];
				}
			}
		}catch(e){}
	}
	changeInputField(a);
}

function getInputSelector(name)
{
	var list = document.getElementsByTagName("INPUT");
	var arr = new Array();
	var n = 0;
	for(var i=0; i<list.length; i++)
	{
		if(list[i].name == name)
		{
			arr[n++] = list[i];
		}
	}
	return arr;
}

function initViewTable(table,row1,row2)
{
	var list = new Array();
	table = $(table);
	row_list = table.getElementsByTagName("tr");
	for(var i=row1; i<row2; i++)
	{
		appendArray(list,row_list[i].getElementByTagName("input"));
		appendArray(list,row_list[i].getElementByTagName("select"));
		appendArray(list,row_list[i].getElementByTagName("textarea"));
		appendArray(list,row_list[i].getElementByTagName("img"));
		deleteLink(row_list[i]);
	}
	changeInputField(list);
}

function deleteLink(div)
{
	div = $(div)
	list = div.getElementsByTagName("a");
	for(var i=list.length-1;i>=0;i--)
	{
		list[i].outerHTML = "";
	}
}
function appendArray(a,b)
{
	len = a.length;
	for(i=0; i<b.length; i++)
	{
		a[len+i]=b[i];
	}
}
function initViewPage(div)
{
	var p = document.body;
	if(div && document.all(div))
	{
		p = document.all(div)
	}
	initDictCheckView(p);
	changeInputField(p.getElementsByTagName("input"));
	changeInputField(p.getElementsByTagName("select"));
	changeInputField(p.getElementsByTagName("textarea"));
	changeImageField(p.getElementsByTagName("img"));
	list = p.getElementsByTagName("a");
	for(var i=list.length-1;i>=0;i--)
	{
		if(list[i].innerText != "\u8FD4\u56DE" && !list[i].viewenable)		//return/back
		{
			list[i].outerHTML = "";
		}
	}
	
}

function initDictCheckView(div)
{
	//dictchec
	var	list = div.getElementsByTagName("checkspan");
	for(var i=list.length-1; i>=0; i--)
	{
		p = list[i].parentNode;
		while(p.tagName.toLowerCase()!="table")
		{
			p = p.parentNode;
		}
		p.outerHTML="<span id=" + list[i].id + ">" + list[i].value + "</span";
	}
}
function changeImageField(list)
{
	for(var i=list.length-1;i>=0;i--)
	{
		if(list[i].viewenable)
		{
			continue;
		}
		if(list[i].outerHTML.indexOf("DateInputInner_onclick")>0)
		{
			list[i].outerHTML = "";
		}
	}
}

function changeInputField(list)
{
	if(list.length<1)
	{
		return;
	}

	for(i=list.length-1;i>=0;i--)
	{
		if(list[i].viewenable)
		{
			continue;
		}
		var x=list[i];
		tag = x.tagName.toUpperCase();
		var type = x.type.toUpperCase();

		if(tag=="TEXTAREA" || type=="TEXT")
		{
			x.outerHTML = "<span>" + x.value + "</span>";
		}
		else if(tag=="SELECT")
		{
			var text = getSelectText(x);
			x.outerHTML = "<span>" + text + "</span>";
		}
		else if(type == "CHECKBOX" || type == "RADIO")
		{
			var s = "";
			while(i>0 && list[i].name==x.name)
			{
				if(list[i].checked)
				{
					s = getCheckText(list[i]) + "," + s;
				}
				i--;
			}
			i++;
			if(s.length>0)
			{
				s = s.substring(0,s.length-1);
			}
			var p = x;
/* not gonna happen, we have already handled this situation before using initDictCheckView()
			if(x.name.indexOf("c_")==0)
			{
				p = x.parentNode;
				while(p.parentNode.tagName!="TD")
				{
					p = p.parentNode;
				}
			}
*/
			p.parentNode.innerHTML = s;
		}	
		else if(tag=="IMG")
		{
			if(x.outerHTML.indexOf("DateInputInner_onclick")>0)
			{
				x.outerHTML = "";
			}
		}		
		removeNextActive(x);
	}
}

	function removeNextActive(x)
	{
		if(x.nextSibling && x.nextSibling.tagName)
		{
			var next = x.nextSibling.tagName.toUpperCase();
			while(next=="IMG" || next=="A")
			{
				if(!x.viewenable)
				x.parentNode.removeChild(x.nextSibling);
				if(x.nextSibling && x.nextSibling.tagName)
				{
					next = x.nextSibling.tagName.toUpperCase();
				}
				else
				{
					return;
				}
			}
		}
	}

function getCheckText(element)
{
	text = "";
	try
	{
		var td = document.createElement("td"); 
		td.appendChild(element.nextSibling);
		text = td.innerText;
	}catch(e){}
	return text;
}

function formatcheck(obj)
{
	var name = obj.name;
	var element = document.getElementById(name.substring(2));
	list = document.getElementsByTagName("INPUT");
	var val = ",";
	for(var i=0;i<list.length;i++)
	{
		if(list[i].checked && list[i].name==name)
		{
			val += list[i].value + ",";
		}
	}
	if(val == ",")
	{
		val = "";
	}
	element.value = val;
}

	function pbuttonDisable()
	{
		var list = document.getElementsByTagName("A");
		for(var i=list.length-1; i>=0; i--)
		{
			if(list[i].className == "pbutton_href")
			{
				var s = list[i].outerHTML
				var p = list[i].parentNode;
				p.removeChild(list[i]);
				p.innerHTML = s.replace("<A","<DIV").replace("</A>","</DIV>");			
			}
		}
	}
	
	function pbuttonEnable()
	{
		var list = document.getElementsByTagName("DIV");
		document.cookie = "token_cookie=" + getCookie("token_cookie").substring(5);
		for(var i=list.length-1; i>=0; i--)
		{
			if(list[i].className == "pbutton_href")
			{
				var s = list[i].outerHTML
				var p = list[i].parentNode;
				p.removeChild(list[i]);
				p.innerHTML = s.replace("<DIV","<A").replace("</DIV>","</A>");				
			}
		}
	}
	
	function resetForm(form)
	{
		pbuttonDisable();
		form = $(form);
		var value = "";
		var list = document.getElementsByTagName("SELECT");

		for(var i=0; i<list.length; i++)
		{
			if(list[i].origin)
			{
				value += list[i].name + "=" + list[i].origin + ";";
			}
		}

		form.reset();
		if(value.length>0)
		{
			
			var arr = value.split(/[=;]/);
			for(var i=0; i<arr.length; i+=2)
			{
				$(arr[i]).value = $(arr[i]).origin = arr[i+1];
			}
		}
		
		for(var i=0; i<form.elements.length; i++)
		{
			if(form.elements[i].type=="hidden" && $("c_" + form.elements[i].name))
			{
				formatcheck($("c_" + form.elements[i].name));
			}
		}
		setMaxLength(form);
		pbuttonEnable();
	}
	
	TextMaxLength = Class.create();
	TextMaxLength.prototype = {
		initialize:function(element,maxLength)
		{
			element = $(element)
			if(maxLength)
			{
				element.maxLength = isNaN(maxLength)?0:parseInt(maxLength,10);
			}
			element.onkeypress = this.doKeypress;
			element.onbeforepaste = this.doBeforePaste;
			element.onpaste = this.doPaste;
			element.onchange = this.doChange;
			this.maxLength = parseInt(element.maxLength);
		},
	  	doKeypress: function() {
	  		//element = Event.srcElement;
			var oTR = this.document.selection.createRange(); 
			// Allow user to type character if at least one character is selected 
			if(oTR.text.length >= 1) 
				event.returnValue = true; 
			else if(this.value.length > this.maxLength-1) 
				event.returnValue = false; 
		},
		doBeforePaste:function(){ 
			if(this.value.length>this.maxLength)
				event.returnValue = false; 
		},
		doPaste:function()
		{ 
			event.returnValue = false; 
			var oTR = this.document.selection.createRange(); 
			var iInsertLength = this.maxLength - this.value.length + oTR.text.length; 
			var sData = window.clipboardData.getData("Text").substr(0,iInsertLength); 
			oTR.text = sData; 
		}, 
		doChange:function()
		{ 
			if(this.value.length>this.maxLength)
			{
				this.value = this.value.substring(0,this.maxLength);
			}
		}, 	
		strlen:function(str)
		{	var i;
			var len;
			len = 0;
			for (i=0;i<str.length;i++)
			{
				if (str.charCodeAt(i)>255) len+=2; else len++;
			}
			return len;
		}
	};
	
		
function reValueSelect()
{
	
	element = event.srcElement;
	try
	{
	    if(element.tagName.toLowerCase()=="select")
		{
			if(element.originSelect.length>0)
			{
				element.value = element.originSelect;
			}
			else
			{
				element.selectedIndex = 0;
			}
		}
	}catch(e){}
}
	
/*

//no limit join select menu
//add by liyongsheng 2007-05-05 
*/
function initJoinSelect(elements,dictionary,condition,value,upelementvalue){
	//init condition
	if(condition=="") condition = " XT_BDDMZB_JC='1' ";//?1??????????//alert(elements);
	var elementArr = elements.split(",");
	if(document.all(elementArr[0])!=null){
		var jc = parseInt(getNumber(condition))+1;
		var newElements = elements.substring(elements.indexOf(",")+1);
		var newElementArr = newElements.split(",");
		condition = base64encode(condition);
		var list;
		if(dict_list.indexOf("," + dictionary + ",")>=0){
			var s = eval("dict_"+dictionary);
			list = s.split(/[=;]/);
		}else{
			var xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
			var url = app_path + "/public/dictionary/dictionarySelect.do?method=getQueryList&XT_TYKJ_KJMC=" + dictionary + "&change=null&CONDITION=" + condition + "&returnList=&returnInputList=&rootName=";
			xmlhttp.Open("POST",url,false);
			xmlhttp.send(null);
			var res=xmlhttp.responseText;
			var doc=new ActiveXObject("MSXML.DOMDocument");
			doc.async=false;
			doc.loadXML(res);
			var root = doc.documentElement;
			list = new Array();
			var oNodeList = root.childNodes;
			for (var i=0; i<oNodeList.length; i++) {
			  	var Item = oNodeList.item(i);
			  	var dc=Item.childNodes;
			  	list[2*i] = dc[0].firstChild.xml;
			  	list[2*i+1] = dc[1].firstChild.xml;
			}
		}
		var defaultvalue = value;
		var f_element_field = elementArr[0];
		var f_elment = $(elementArr[0]);
		
		if(f_elment.value!=""){
			defaultvalue = f_elment.value;
		}
		
		if(elementArr.length == 2){
			var strOption="<SELECT style='width:120px' NAME='" + elementArr[0] + "' origin='" + defaultvalue + "' onchange=initPreSelect('"+newElements+"','"+dictionary+"',this.value,"+jc+") />";
		}else{
			var strOption="<SELECT style='width:120px' NAME='" + elementArr[0] + "' origin='" + defaultvalue + "' onchange=initPreJoinSelect('"+newElements+"','"+dictionary+"',this.value,"+jc+") />";
		}
		var op=document.createElement(strOption);
		op.options[0]=new Option("\u8BF7\u9009\u62E9","");
		var selectedText = defaultvalue;
		for(var i=0; i<list.length/2; i++){
		 	op.options[i+1]=new Option(list[2*i+1],list[2*i]);
			if(list[2*i]==defaultvalue||list[2*i+1]==defaultvalue){
		        op.options[i+1].selected=true;
			}
		}
		if(!op.selectedIndex || op.selectedIndex<0){
			op.selectedIndex=0;
			op.origin="";
		}
		if(page_type=="view" && f_elment.tagName.toLowerCase()=="span"){
			var sText = "";
			if(op.selectedIndex && op.selectedIndex>0){
				sText = op[op.selectedIndex].text;
			}
			f_elment.innerText = sText;
		}else{
			p = f_elment.parentNode;
			p.insertBefore(op,f_elment);
			p.removeChild(f_elment);
		}	
		
		if(defaultvalue == ""||defaultvalue == null) defaultvalue = "safdlkjdsafedfdekjioiklklklsasfddsfdsfkilioioioi";
		
		if(elementArr.length == 2){
			initSelect(newElements,dictionary," XT_BDDMZB_JC='"+jc+"' and xt_bddmzb_bm like '"+defaultvalue+"%' ")
		}else{
			if(document.all(newElementArr[0])!=null){
				initJoinSelect(newElements,dictionary," XT_BDDMZB_JC='"+jc+"' and xt_bddmzb_bm like '"+defaultvalue+"%' ",value,document.all(newElementArr[0]).value)
			}
		}
		}
	}
	
	function initPreSelect(element,dic,selectValue,jc){
		if(selectValue == null|| selectValue == "") selectValue = "sdfsadfadsfdsafadsfasfasfasdflkjlkjljldfslkj";
		initSelect(element,dic," XT_BDDMZB_JC='"+jc+"' and xt_bddmzb_bm like '"+selectValue+"%' ",'');
	}	
	function initPreJoinSelect(elements,dic,selectValue,jc){
		if(selectValue == null|| selectValue == "") selectValue = "sdfsadfadsfdsafadsfasfasfasdflkjlkjljldfslkj";
		
		initJoinSelect(elements,dic," XT_BDDMZB_JC='"+jc+"' and xt_bddmzb_bm like '"+selectValue+"%' ",'');
		var elementArrInit = elements.split(",");
		for(var m = 0;m<elementArrInit.length;m++){
			document.all(elementArrInit[m]).value="";
		}					
	}	
		
	var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 
	function base64encode(str) { 
	    var out, i, len; 
	    var c1, c2, c3; 
	
	    len = str.length; 
	    i = 0; 
	    out = ""; 
	    while(i < len) { 
	    c1 = str.charCodeAt(i++) & 0xff; 
	    if(i == len) 
	    { 
	        out += base64EncodeChars.charAt(c1 >> 2); 
	        out += base64EncodeChars.charAt((c1 & 0x3) << 4); 
	        out += "=="; 
	        break; 
	    } 
	    c2 = str.charCodeAt(i++); 
	    if(i == len) 
	    { 
	        out += base64EncodeChars.charAt(c1 >> 2); 
	        out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4)); 
	        out += base64EncodeChars.charAt((c2 & 0xF) << 2); 
	        out += "="; 
	        break; 
	    } 
	    c3 = str.charCodeAt(i++); 
	    out += base64EncodeChars.charAt(c1 >> 2); 
	    out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4)); 
	    out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6)); 
	    out += base64EncodeChars.charAt(c3 & 0x3F); 
	    } 
	    return out ; 
	}
	
function getNumber(String){ 
	var Letters = "1234567890"; 
	var i; 
	var c; 
	for( i = 0; i < String.length; i++ ) { 
		c = String.charAt( i ); 
		if (Letters.indexOf(c) !=-1) { 		
			return c; 
		} 
	} 
} 


function viewOnly(elements){
	var elementArr = elements.split(",");

	if(elementArr.length<1)
	{
		return;
	}

	for(i=elementArr.length-1;i>=0;i--)
	{
		var x=$(elementArr[i]);
		tag = x.tagName.toUpperCase();
		
		var type = x.type;
		
		if(type != null){
			type = type.toUpperCase();
		}		

		if(tag=="TEXTAREA" || type=="TEXT")
		{
			x.outerHTML = "<span>" + x.value + "</span>";
		}
		else if(tag=="SELECT")
		{
			var text = getSelectText(x);
			x.outerHTML = "<span>" + text + "</span>";
		}
		else if(type == "CHECKBOX" || type == "RADIO")
		{
			var s = "";
			while(i>0 && list[i].name==x.name)
			{
				if(list[i].checked)
				{
					s = getCheckText(list[i]) + "," + s;
				}
				i--;
			}
			i++;
			if(s.length>0)
			{
				s = s.substring(0,s.length-1);
			}
			var p = x;

			p.parentNode.innerHTML = s;
		}	
		else if(tag=="IMG")
		{
			//alert(x.outerHTML);
			//if(x.outerHTML.indexOf("DateInputInner_onclick")>0)
			//{
				x.outerHTML = "";
			//}
		}		
		removeNextActive(x);
	}
}
